package com.noahplat.person.mapper;

import com.noahplat.person.pojo.MedicalRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @InterfaceName: MedicalRecordMapper
 * @Description: 就诊记录mapper
 * @Author 李景星
 * @Date 2021/3/6
 * @Version 1.0
 */
public interface MedicalRecordMapper extends Mapper<MedicalRecord> {

    /**
     * 查询就诊记录，（携带一级和二级分类名称）
     * @param pid
     * @return
     */
    @Select("select m.id, m.pid, m.hospital, m.first_depart, m.second_depart, m.visit_time as vtime , m.description, m.result, m.filepath, m.del, f.first_depart as fdepartName, s.second_depart as sdepartName from tb_medical_record m INNER JOIN enum_first_depart f on m.first_depart=f.id INNER JOIN enum_second_depart s on m.second_depart=s.id where pid=#{pid} and del='N' order by id desc")
    public List<MedicalRecord> getMedicalRecords(@Param("pid") Long pid);

}
